<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="Effects - Bimrun Engine v3.7" content="width=device-width, initial-scale=1.0">
    <title>Bimrun Engine v3.7</title>
</head>

<body style=" margin: 0; padding: 0; overflow: hidden; ">

    <div id="container" style=" margin: 0; padding: 0; width: 100%; height: 100%; position: absolute; "></div>

    <div id="desc" style=" margin: 10px; padding: 0px; position: absolute; bottom: 0px; ">

        <input type="button" value="添加剖面" id="addClippingPlane" />
        <input type="button" value="添加剖面盒" id="addClippingBox" />
        <input type="button" value="删除单个剖面" id="delClippingPlane" />
        <input type="button" value="删除所有剖面" id="delAllClippingPlane" />
        <input type="button" value="显示或隐藏所有剖面" id="displayAllClippingPlane" />
        <input type="button" value="显示材质填充" id="showRenderCap" />


    </div>

    <script src='depends/config.js'></script>
    <script src='bimrun-engine-v3.7.js'></script>

    <script>

        let viewer = window.viewer = new Viewer( {

            container: document.getElementById( "container" ),
            indicator: { url: "../resources/aim.png", size: 50 }

        } );

        viewer.createNavCube( viewer.container );

        viewer.loadScene( '131538867' ); // 关闭加载场景时的自带视角动画 伊犁路办公室

        // 2020-06-11 yaoyuan: 剖面相关
        let clipPlanes = [];
        // 2020-06-11 yaoyuan: 添加剖面
        document.getElementById( "addClippingPlane" ).addEventListener( 'click', () => {
            // var plane = viewer.addClippingPlane( { x: 0, y: 0, z: 0 }, { x: 0, y: 0, z: 1 }, 100, 100, Math.round( Math.random() * 16777215 ), 0.2 );
            // clipPlanes.push( plane );

            // var plane = viewer.addClippingPlane( { x: 0, y: 0, z: 0 }, { x: 0, y: 1, z: 0 }, 100, 100, Math.round( Math.random() * 16777215 ), 0.2 );
            // clipPlanes.push( plane );
            var plane = viewer.addClippingPlane( { x: -2.8759986377302504, y: -110.24105493758269, z: 1.4395101325802817 }, { x: -1, y: 0, z: 0 }, 100, 100, Math.round( Math.random() * 16777215 ), 0.2 );
            clipPlanes.push( plane ); //伊犁路办公室

            // let plane = viewer.addClippingPlane( { x: 18370.259520710275, y: 62559.76510425813, z: 768.3489999999999 }, { x: 0, y: 0, z: -1 }, 1000, 1000 );
            // clipPlanes.push( plane );
            // plane = viewer.addClippingPlane( { x: 18370.259520710275, y: 62559.76510425813, z: 761.658 }, { x: 0, y: 0, z: 1 }, 1000, 1000 );
            // clipPlanes.push( plane );
        } );

        // 2020-06-11 yaoyuan: 添加剖面盒
        document.getElementById( "addClippingBox" ).addEventListener( 'click', () => {
            let planes = viewer.addClippingBox( { x: -2.8759986377302504, y: -110.24105493758269, z: 1.4395101325802817 }, 40, 40, 40 );
            clipPlanes = clipPlanes.concat( planes ); //伊犁路办公室
        } );

        // 2020-06-11 yaoyuan: 删除单个剖面
        document.getElementById( "delClippingPlane" ).addEventListener( 'click', () => {
            clipPlanes.pop().deleteClippingPlane();
        } );

        // 2020-06-11 yaoyuan: 删除所有剖面
        document.getElementById( "delAllClippingPlane" ).addEventListener( 'click', () => {
            viewer.deleteAllClippingPlanes();
        } );

        // 2020-11-30 mwq: 隐藏所有剖面
        let clippingPlaneVisibility = true;
        document.getElementById( "displayAllClippingPlane" ).addEventListener( 'click', () => {
            clippingPlaneVisibility = !clippingPlaneVisibility;
            viewer.displayAllClippingPlanes( clippingPlaneVisibility );
        } );

        // 2020-12-18 mwq: 添加showCap按钮
        let showRenderCap = false;
        document.getElementById( "showRenderCap" ).addEventListener( 'click', () => {
            showRenderCap = !showRenderCap;
            viewer.showClippingPlaneCap( showRenderCap );
        } );

    </script>
</body>

</html>